/**
 * @(#) PopWelfareHistoryMediator
 *
 * @date		2011. 03. 19.
 * @version		1.0
 * @author		baek, kwanghoyun
 * @description	복리후생 - 선택적복리후생 포인트 내역조회 - Mediator
 * 				선택적 복리후생 신청 Presentation Logic을 관리 
 */
package com.skt.common_hr.welfare.view
{
	import com.skt.common_hr.common.Variables;
	import com.skt.common_hr.common.puremvc.CommonMediator;
	import com.skt.common_hr.welfare.WelfareFacade;
	import com.skt.common_hr.welfare.model.popWelfareHistoryProxy;
	import com.skt.common_hr.welfare.model.vo.WelfareHistoryVO;
	import com.skt.common_hr.welfare.view.components.popHistory;
	
	import flash.events.Event;
	
	import mx.managers.PopUpManager;
	
	import org.puremvc.as3.multicore.interfaces.INotification;
	
	public class PopWelfareHistoryMediator extends CommonMediator
	{
		public static const NAME:String = "PopWelfareHistoryMediator"; 
		public var hisotryVo:WelfareHistoryVO = null;		
	    
//	    private var VALIDATION_MSG:String = "";
//		public var Gkey:String;
//		public var restMoney:Number = 0;

		/**
		* 생성자
		* 
		* @param
		* @return void
		*/
        public function PopWelfareHistoryMediator( viewComponent:Object )
        {
            super( NAME, viewComponent );
            
        }
 		
		/**
		* View를 초기화 한다.
		*	- View에 기본사항을 출력하고 data를 load
		* @param
		* @return void
		*/
		override protected function initializeView():void
 		{
 			view.addEventListener(popHistory.CancelInput, onCancel);
 		
 		}
 		
		public function exec(year:String):void {
			onList(year);
		}
		
 		public function onList(year:String):void
 		{
	 		var proxy:popWelfareHistoryProxy = facade.retrieveProxy(popWelfareHistoryProxy.NAME) as popWelfareHistoryProxy;
	 		proxy.historyLoad(Variables.myPernr, year);
 		}


  		private function onCancel(event:Event):void
 		{
				facade.removeMediator(PopWelfareHistoryMediator.NAME);
				PopUpManager.removePopUp(view); 			
 			//facade.sendNotification(WelfareFacade.CANCEL_WELFARE, this);
 		} 
 		
		///////////////////////////////////////////////////////////////////////////////////////////////////
		//
		//	Process MVC Messages
		//
		///////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		* 본 Class에서 처리해야할 Noti들을 등록한다.
		* 
		* @param
		* @return void
		*/
		override public function listNotificationInterests():Array 
		{
			return [
					WelfareFacade.LOAD_WELFARE_HISTORY_COMPLETE
					];
		}
		

		/**
		* Noti별로 처리한다.
		* 
		* @param
		* @return void
		*/
		override public function handleNotification(note:INotification):void
		{
			
			switch(note.getName()) 
			{				
				case WelfareFacade.LOAD_WELFARE_HISTORY_COMPLETE:
					view.welfareList = (note.getBody() as popWelfareHistoryProxy).welfareList;
					break;
					
				default:
					//trace(this.instanceID+"에서 처리 안된 Noti가 검출됨 : " + note.getBody());
					break;
			}
			
		}
		
		///////////////////////////////////////////////////////////////////////////////////////////////////
		//
		//	Utility Functions
		//
		///////////////////////////////////////////////////////////////////////////////////////////////////
        private function get view():popHistory
        {
            return viewComponent as popHistory;
        }
	}
}